package com.wzh.house.service.impl;

import com.wzh.common.utils.R;
import com.wzh.house.entity.NewHouseEntity;
import com.wzh.house.entity.RentHouseEntity;
import com.wzh.house.entity.RentImgEntity;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.wzh.common.utils.PageUtils;
import com.wzh.common.utils.Query;

import com.wzh.house.dao.NewImgDao;
import com.wzh.house.entity.NewImgEntity;
import com.wzh.house.service.NewImgService;


@Service("newImgService")
public class NewImgServiceImpl extends ServiceImpl<NewImgDao, NewImgEntity> implements NewImgService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        QueryWrapper<NewImgEntity> w = new QueryWrapper<>();
        w.eq("house_id",params.get("houseId"));
        IPage<NewImgEntity> page = this.page(
                new Query<NewImgEntity>().getPage(params),
                w
        );

        return new PageUtils(page);
    }

    @Override
    public R loadImgs(Integer houseId) {
        List<NewImgEntity> imgs = baseMapper.selectList(new QueryWrapper<NewImgEntity>().eq("house_id", houseId));
        return R.ok().put("imgs",imgs);
    }

    @Override
    public void removeByHouseId(Integer houseId) {
        baseMapper.removeByHouseId(houseId);
    }

}